# SET(CUR_ARCH "aarch64")
SET(CUR_ARCH "armhf")
# SET(CUR_ARCH "x86_64")
SET(PREFIX "/home/sunjie")


SET(CMAKE_CXX_FLAGS "-fPIC -std=c++14 -ldl -Wall -Wextra -Wunused-parameter -Wl,--copy-dt-needed-entries")
SET(EXTERNAL_LIB "-ldl -lrt -lm -lpthread")

SET(UTILS_DIR ${PROJECT_SOURCE_DIR}/src/base_util)
SET(CAMERA_DIR ${PROJECT_SOURCE_DIR}/src/camera)
SET(APP_DIR ${PROJECT_SOURCE_DIR}/src/app)
SET(COMMON_DIR ${PROJECT_SOURCE_DIR}/src/common)
SET(ACTIVATE_DIR ${PROJECT_SOURCE_DIR}/src/activate_code)

SET(MODEL_SOURCE
${UTILS_DIR}/utils.cpp
${UTILS_DIR}/base64.cpp

${COMMON_DIR}/common_tool.cpp
${COMMON_DIR}/modbus_api.cpp
${COMMON_DIR}/http_tool.cpp
${COMMON_DIR}/video_tool.cpp

${ACTIVATE_DIR}/activate_code.cpp

${CAMERA_DIR}/hiknet/hiknet.cpp
${CAMERA_DIR}/hiknet/hikutil.cpp

${APP_DIR}/camera_manager.cpp
${APP_DIR}/smartbox.cpp
${APP_DIR}/local_tool.cpp
${APP_DIR}/main.cpp
)

SET(TARGET_NAME sewage_cli)
add_executable(${TARGET_NAME} ${MODEL_SOURCE})
# add_library(${TARGET_NAME} SHARED ${MODEL_SOURCE})
# set_target_properties(${TARGET_NAME} PROPERTIES VERSION 1.0.0 SOVERSION 1)

include_directories(${PROJECT_SOURCE_DIR}/src)

# boost
SET(BOOST_PATH "${PREFIX}/work/lib/boost_1_67_0")
set(BOOST_LIB
    ${BOOST_PATH}/stage/lib.${CUR_ARCH}/libboost_filesystem.a
    ${BOOST_PATH}/stage/lib.${CUR_ARCH}/libboost_system.a
    ${BOOST_PATH}/stage/lib.${CUR_ARCH}/libboost_date_time.a
    ${BOOST_PATH}/stage/lib.${CUR_ARCH}/libboost_regex.a
)
include_directories(${BOOST_PATH})
target_link_libraries(${TARGET_NAME} ${BOOST_LIB})

# opencv
SET(OPENCV_PATH "${PREFIX}/work/lib/opencv-4.5.2/install.ffmpeg.${CUR_ARCH}")
set(OPENCV_LIB ${OPENCV_PATH}/lib/libopencv_world.so.4.5.2)
include_directories(${OPENCV_PATH}/include/opencv4)
target_link_libraries(${TARGET_NAME} ${OPENCV_LIB})


# ffmpeg
SET(FFMPEG_PATH "${PREFIX}/work/lib/ffmpeg_build.${CUR_ARCH}")
set(FFMPEG_LIB
    ${FFMPEG_PATH}/lib/libavcodec.so.58
    ${FFMPEG_PATH}/lib/libavformat.so.58
    ${FFMPEG_PATH}/lib/libavdevice.so.58
    ${FFMPEG_PATH}/lib/libavutil.so.56
    ${FFMPEG_PATH}/lib/libswresample.so.3
    ${FFMPEG_PATH}/lib/libx264.so.164
    # ${FFMPEG_PATH}/lib/libpostproc.so.55
    # ${FFMPEG_PATH}/lib/libavresample.so.4
    # ${FFMPEG_PATH}/lib/libavfilter.so.7
    # ${FFMPEG_PATH}/lib/libswscale.so.5
)
include_directories(${FFMPEG_PATH}/include)
target_link_libraries(${TARGET_NAME} ${FFMPEG_LIB})

# json
SET(JSONCPP_PATH "${PREFIX}/work/lib/jsoncpp-1.9.5/install.${CUR_ARCH}")
set(JSONCPP_LIB ${JSONCPP_PATH}/lib/libjsoncpp.a)
include_directories(${JSONCPP_PATH}/include)
target_link_libraries(${TARGET_NAME} ${JSONCPP_LIB})

# spdlog
SET(SPDLOG_PATH "${PREFIX}/work/lib/spdlog-1.9.2/install.${CUR_ARCH}")
set(SPDLOG_LIB ${SPDLOG_PATH}/lib/libspdlog.a)
include_directories(${SPDLOG_PATH}/include)
target_link_libraries(${TARGET_NAME} ${SPDLOG_LIB})

# modbus
SET(MODBUS_PATH "${PREFIX}/work/lib/libmodbus-3.0.8/install.${CUR_ARCH}")
set(MODBUS_LIB ${MODBUS_PATH}/lib/libmodbus.so.5.0.5)
include_directories(${MODBUS_PATH}/include)
target_link_libraries(${TARGET_NAME} ${MODBUS_LIB})


target_link_libraries(${TARGET_NAME} ${CMAKE_CXX_FLAGS} ${EXTERNAL_LIB})

